package com.aierjun.test;


import android.os.Bundle;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.aierjun.test.utils.LogUtils;

import org.apache.cordova.CordovaActivity;
import org.apache.cordova.CordovaChromeClient;
import org.apache.cordova.CordovaWebView;
import org.apache.cordova.CordovaWebViewClient;

/**
 * Created by aierJun on 2016/12/22.
 */
public class ImageActivity extends CordovaActivity{
    private FrameLayout root;
    private ImageView imageView;
    private CordovaWebView webView;
    private Button button;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_image_test_two);
        findView();
        initView();
        te();
    }

    private void findView() {
        root= (FrameLayout) findViewById(R.id.root_test);
        webView= (CordovaWebView) findViewById(R.id.image_test);
        button= (Button) findViewById(R.id.go);
    }

    private void initView() {
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (imageView==null){
                    imageView=new ImageView(ImageActivity.this);
                    imageView.setImageResource(R.drawable.icon);
                    ImageActivity.this.root.addView(imageView);
                }else{
                    ImageActivity.this.root.removeView(imageView);
                    imageView=null;
                }
            }
        });
    }
    public void te(){
       /* CordovaChromeClient a=webView.getWebChromeClient();
        a.onShowCustomView(webView, new WebChromeClient.CustomViewCallback() {
            @Override
            public void onCustomViewHidden() {

            }
        });
        a.onProgressChanged(webView,100);*/
        webView.loadUrl("http://www.woxiangwoxiang.com:8013");
    }







   /* @Override
    public void init() {
        this.init(webView, new CordovaWebViewClient(this, webView) {
            // 页面加载完成事件
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                LogUtils.LogUtils("........shouldOverrideUrlLoading............");
                return super.shouldOverrideUrlLoading(view,url);
            }
        }, new CordovaChromeClient(this, webView) {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                LogUtils.LogUtils("........onProgressChanged............");
                super.onProgressChanged(view, newProgress);
            }
        });
    }*/
}
